﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Orchard.Model
{
    class OrchardModel
    {
        //keep track of program state
        DateTime currentDate;

        //dates for keeping track of when sections were last updated
        DateTime productivityDate;
        DateTime learningDate;
        DateTime exerciseDate;

        // Lumberjack will have one instance of a tree for every living tree.
        Tree productivityTree;
        Tree exerciseTree;
        Tree learningTree;
        
        // Lumberjack will have one instance of lumber for every group of dead trees.
        Lumber productivityLumber;
        Lumber exerciseLumber;
        Lumber learningLumber;

        //properties
        public DateTime ProductivityDate
        {
            get { return productivityDate; }
            set { productivityDate = value; }
        }

        public Tree ProductivityTree
        {
            get { return productivityTree; }
            set { productivityTree = value; }
        }

        public DateTime LearningDate
        {
            get { return learningDate; }
            set { learningDate = value; }
        }

        public Tree LearningTree
        {
            get { return learningTree; }
            set { learningTree = value; }
        }

        public DateTime ExerciseDate
        {
            get { return exerciseDate; }
            set { exerciseDate = value; }
        }

        public Tree ExerciseTree
        {
            get { return exerciseTree; }
            set { exerciseTree = value; }
        }

        public DateTime CurrentDate
        {
            get { return currentDate; }
            set { currentDate = value; }
        }

        //constructor
        public OrchardModel()
        {
            productivityTree = new Tree(TreeTypeEnum.ProductivityTree);
            exerciseTree = new Tree(TreeTypeEnum.ExerciseTree);
            learningTree = new Tree(TreeTypeEnum.LearningTree);
            productivityLumber = new Lumber();
            exerciseLumber = new Lumber();
            learningLumber = new Lumber();

            //initialize the current day to the date the program is run
            currentDate = new DateTime(2009, 6, 1); // June 1, 2009 is when the dates start on the user eval instructions.

            //TEMPORARY INITIALIZE FOR TESTING
            productivityDate = currentDate;
            learningDate = currentDate;
            exerciseDate = currentDate;
        }

        public bool productivityUpToDate()
        {
            //take difference between the days
            return currentDate.AddDays(1).Subtract(productivityDate).Days == 0;
        }

        public bool learningUpToDate()
        {
            //take difference between the days
            return currentDate.AddDays(1).Subtract(learningDate).Days == 0;
        }

        public bool exerciseUpToDate()
        {
            //take difference between the days
            return currentDate.AddDays(1).Subtract(exerciseDate).Days == 0;
        }
    }
}
